$(function(){
	tableLB();
	tableTJ();
	tableZL();
	
	//新增显示
	$("#QinJiaadd").click(function(){
		$("#QinJiawin").window("open");
	});
});

function tableLB(){
	//初始化表格
	$('#QinJiadLieBiao').datagrid({
	    url:'QinJiaLieBiao',
	    /* queryParams:{
	    	deptno:10
	    }, */
	    columns:[[
			{field:'LAEID',width:1,checkbox:true,title:'请假编号',align:'center',hidden:true},
			{field:'EMPNAME',width:1,title:'员工姓名',align:'center'},
			{field:'DEPTNAME',width:1,title:'部门',align:'center'},
			{field:'CWASID',width:1,title:'所属考勤卡',align:'center'},
			{field:'TEMNAME',width:1,title:'班组名称',align:'center'},
			{field:'SHFNAME',width:1,title:'班次',align:'center'},
			{field:'SHFREM',width:1,title:'班次时间',align:'center'},
			{field:'TYPEZL',width:1,title:'请假原因',align:'center'},
			{field:'TYPEXZ',width:1,title:'请假类型',align:'center'},
			{field:'LAEMINTIME',fwidth:1,title:'请假开始时间',align:'center',
				formatter: function(value,row,index){
					return new Date(value).getFullYear() + '-' + (new Date(value).getMonth() + 1) + '-' + new Date(value).getDate() + ' ' + new Date(value).getHours() + ':' + new Date(value).getMinutes() + ':' + new Date(value).getSeconds();
				}
			},
			{field:'LAEMAXTIME',fwidth:1,title:'请假结束时间',align:'center',
				formatter: function(value,row,index){
					return new Date(value).getFullYear() + '-' + (new Date(value).getMonth() + 1) + '-' + new Date(value).getDate() + ' ' + new Date(value).getHours() + ':' + new Date(value).getMinutes() + ':' + new Date(value).getSeconds();
				}
			},
			{field:'LAETIME',width:1,title:'请假时长',align:'center'}
	    ]],
	    toolbar:'#QinJiatb',
	    pagination:true,
	    pageNumber:1,
	    pageSize:5,
	    pageList:[5,10,15]
	});
}

function tableTJ(){
	//初始化表格
	$('#QinJiaTongJi').datagrid({
	    url:'QinJiaTongJi',
	    /* queryParams:{
	    	deptno:10
	    }, */
	    columns:[[
			{field:'LAEID',width:1,checkbox:true,title:'请假编号',align:'center'},
			{field:'EMPNAME',width:1,title:'员工姓名',align:'center'},
			{field:'DEPTNAME',width:1,title:'部门',align:'center'},
			{field:'CWASID',width:1,title:'所属考勤卡',align:'center'},
			{field:'TEMNAME',width:1,title:'班组名称',align:'center'},
			{field:'SHFNAME',width:1,title:'班次',align:'center'},
			{field:'SHFREM',width:1,title:'班次时间',align:'center'},
			{field:'LAETIME',width:1,title:'请假时长',align:'center'}
	    ]],
	    pagination:true,
	    pageNumber:1,
	    pageSize:5,
	    pageList:[5,10,15]
	});
}

function tableZL(){
	$('#QinJiadgZhongLei').datagrid({
	    url:'QinJiaZhongLei',
	    /* queryParams:{
	    	deptno:10
	    }, */
	    columns:[[
			{field:'TYPEID',width:1,checkbox:true,title:'请假编号',align:'center'},
			{field:'TYPEZL',width:1,title:'请假种类',align:'center'},
			{field:'TYPEXZ',width:1,title:'请假性质',align:'center'},
			{field:'TYPEDX',width:1,title:'是否带薪',align:'center'},
			{field:'TYPETIME',fwidth:1,title:'规定期限',align:'center'}
	    ]],
	    pagination:true,
	    pageNumber:1,
	    pageSize:5,
	    pageList:[5,10,15]
	});
}

function tabledata(){
	Date.prototype.Format = function(fmt) { //author: meizz 
	  var o = { 
	    "M+" : this.getMonth()+1,                 //月份 
	    "d+" : this.getDate(),                    //日 
	    "h+" : this.getHours(),                   //小时 
	    "m+" : this.getMinutes(),                 //分 
	    "s+" : this.getSeconds(),                 //秒 
	    "q+" : Math.floor((this.getMonth()+3)/3), //季度 
	    "S"  : this.getMilliseconds()             //毫秒 
	  }; 
	  if(/(y+)/.test(fmt)) {
		  fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); 
	  }
	  for(var k in o) {
		  if(new RegExp("("+ k +")").test(fmt)) {
			  fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length))); 
			  return fmt; 
		  }
	  }
	}
}
